<template>
    <div class="app-container">

        <div class="card-wrap flex-column justify-end card-padding">

            <div class="card-title-wrap">
                <span>基本信息</span>
                <span></span>
            </div>

            <el-descriptions title="">
                <el-descriptions-item label="公司名称">{{ form.companyName|filterNull }}</el-descriptions-item>
                <el-descriptions-item label="地址">{{ form.companyAddr|filterNull }}</el-descriptions-item>
                <el-descriptions-item label="联系人">{{ form.contact|filterNull }}</el-descriptions-item>
                <el-descriptions-item label="联系电话">{{ form.contactPhone|filterNull }}</el-descriptions-item>
                <el-descriptions-item label="税号">
                    {{ form.taxpayerIdentityNumber|filterNull }}
                </el-descriptions-item>
                <el-descriptions-item label="开户名称">{{ form.bankAccountName|filterNull }}</el-descriptions-item>
                <el-descriptions-item label="开户银行">{{ form.bankName|filterNull }}</el-descriptions-item>
                <el-descriptions-item label="银行账号">{{ form.bankAccountNumber|filterNull }}</el-descriptions-item>

                <el-descriptions-item label="备注">{{ form.memo|filterNull }}</el-descriptions-item>

                <el-descriptions-item label="营业执照或公示截图">
                    <div class="flex">
                        <ImageCommon disabled :src="form.businessLicenseFrontImg"></ImageCommon>
                        <!--            <ImagePreview :src="getUrl(form.businessLicenseFrontImg)"></ImagePreview>-->
                    </div>
                </el-descriptions-item>

                <el-descriptions-item label="附件">
                    <div class="flex">
                        <ImageCommon disabled v-model="form.annex"></ImageCommon>
                        <!--            <FilePreview :fileList="getUrl(form.annex)"></FilePreview>-->
                    </div>
                </el-descriptions-item>

            </el-descriptions>

        </div>


        <!--    <div class="card-wrap flex justify-end card-padding">-->
        <!--      <el-button @click="cancel">取消</el-button>-->
        <!--      <el-button :loading="buttonLoading" type="primary" @click="submitForm">保存</el-button>-->
        <!--    </div>-->

    </div>
</template>

<script>


import FilePreview from "@/components/FilePreview/index.vue";
import {driverCompanyDetail} from "@/api/memberManage/driverList";

export default {
    name: "laberCompanyDetail",
    components: {
        FilePreview,
    },
    data() {
        return {
            buttonLoading: false,
            form: {},
            activeName: 'first'
        };
    },
    watch:{
        '$route':{
            handler(val){
                console.log('this.$route', this.$route)

                if(val && val.name==this.$options.name){
                    if (this.$route.query && this.$route.query.companyId && !this.$route.query.tabClick) {
                        this.getOldData(this.$route.query.companyId)
                    }
                    else if(!this.$route.query.tabClick){
                        this.form = {}
                    }

                }
            },
            immediate:true,
            deep:true
        }
    },
    // mounted() {
    //     if (this.$route.query) {
    //         this.getOldData(this.$route.query.companyId)
    //     }
    // },
    methods: {
        getOldData(companyId) {
            driverCompanyDetail(companyId).then(res => {
                this.form = res.data
            })
        },
        getUrl(ossid) {
            ossid = String(ossid)
            if (ossid && ossid.indexOf(",") != -1) {
                let split = ossid.split(",");

                let res = this.form.ossVos.filter(item => {
                    for (let splitElement of split) {
                        if (item.ossId == splitElement) {
                            return item
                        }
                    }

                }).map(item => {
                    return item.url
                })
                console.log('aaa', res)
                return res

            } else {
                if (this.form.ossVos && this.form.ossVos.length) {
                    return this.form.ossVos.find(item => {
                        if (item.ossId == ossid) {
                            return item
                        }
                    })?.url
                }
            }
        },
    }
};
</script>


<style lang="scss" scoped>


</style>
